/*
 * @Author       : shenqing
 * @desc         : 适配
 * @Date         : 2020-07-01 10:51:42
 * @LastEditTime : 2022-10-11 15:02:42
 * @LastEditors  : shenqing
 * @FilePath     : \questionnaire\src\mixins\adoptdevicemixin.js
 */
export default {
    data() {
        return {}
    },
    computed: {
        cachedViews() {
            return 'app1'
        },
        key() {
            return this.$route.fullPath
        }
    },
    created() {
        this.$nextTick(() => {
            let _this = this
            if(_this.clientCategory === 'PC') _this.adoptdevicePc()
            if(_this.clientCategory === 'H5') _this.adoptdeviceH5()
            window.addEventListener('resize', e => {
                setTimeout(() => {
                    if(_this.clientCategory === 'PC') _this.adoptdevicePc()
                    if(_this.clientCategory === 'H5') _this.adoptdeviceH5()
                }, 200)
            })
        })
    },
    methods: {
        // pc适配
        adoptdevicePc() {
            var htmlWidth =
                document.documentElement.clientWidth ||
                document.body.clientWidth
            var htmlDom = document.getElementsByTagName('html')[0]
            if (htmlWidth >= 1360) {
                htmlDom.style.fontSize = htmlWidth / 19.2 + 'px'
            } else {
                htmlDom.style.fontSize = '73.3854px'
            }
        },
        // h5适配
        adoptdeviceH5(){
            let html = document.documentElement
            let hWidth = html.clientWidth
            if (hWidth > 768) {
                hWidth = 414
            }
            if (document.documentElement.children[1].baseURI.includes("DM")) {
                html.style.fontSize = "100px"
            } else {
                html.style.fontSize = (hWidth / 375) * 100 + "px"
            }
        }
    }
}
